//
//  PeopleCenterToolkit.m
//  HMSupplier
//
//  Created by haohao on 2017/7/21.
//  Copyright © 2017年 haohao. All rights reserved.
//

#import "PeopleCenterToolkit.h"

@implementation PeopleCenterToolkit

+ (NSMutableArray *)addSearchText:(NSMutableArray *)dataArray searchText:(NSString *)text {
    NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"SELF == %@", text];
    NSArray *results1 = [dataArray filteredArrayUsingPredicate:predicate1];
    if (results1.count == 0) {
        [dataArray addObject:text];
    }
    return dataArray;
}

+ (NSDateComponents *)timestampSwitchTime:(NSInteger)timestamp{
    NSString *format = @"YYYY-MM-dd hh:mm:ss";
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:format];
    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    [formatter setTimeZone:timeZone];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timestamp];
    
    
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    NSDateComponents *comps = [[NSDateComponents alloc] init];
    NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday |
    NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
    comps = [calendar components:unitFlags fromDate:confromTimesp];
    
    return comps;
    
}

@end
